<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script type='text/javascript' src='js/vue.js'></script>
</head>

<body>
    <div id='app'>
        {{msg}}===={{mm}}
        <hr>

        <father @qqq='show'></father>
    </div>
    <script type='text/javascript'>

/* 
步骤：
1、子组件触发事件调用$emit()函数
2、$emit()触发父组件身上的事件
3、父组件的事件触发了调用函数
4、函数的形参获取子组件传递过来的参数

 */
        var father = {
            data() {
                return {
                    ff: 'father====我要把值传给app'
                }
                
            },
            // template:`<h1 @click="$emit('qqq')">我是father组件</h1>`
            template:`<h1 @click="sonShow">我是father组件</h1>`,
            methods:{
                sonShow(){
                    this.$emit('qqq',this.ff)
                }
            }
        }
        Vue.component('father',father)

        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'Hello Vue',
                mm:''
            },
            methods:{
                show(message){
                    console.log(message,1234);
                    this.mm=message
                }
            }
        });
    </script>
</body>

</html>